package edu.friday_2025_04_27.model.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import edu.friday_2025_04_27.model.SysRole;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysUserVO implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;

    @NotBlank(message = "用户名称不能为空")
    @Size(min = 0,max = 30,message = "用户账号名称长度不能超过30个字符")
    private String userName;

    @Size(min = 0,max = 30,message = "用户账号名称长度不能超过30个字符")
    private String nickName;

    private String userType;

    @NotBlank(message = "邮箱不能为空")
    @Size(min = 0,max = 50,message = "邮箱长度不能超过50个字符")
    private String email;


    @Size(min = 0,max = 11,message = "手机号码长度不能超过11个字符")
    private String phonenumber;

    private Character sex;

    private String avatar;

    private String password;

    private Character status;

    private Character delFlag;

    private String loginIp;

    private Date loginDate;
//
    private String createBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private String updateBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    private String remark;
//
    private List<SysRole> roles;

    private Long[] roleIds;

    public SysUserVO(Long id) {
        this.id = id;
    }

    public boolean isAdmin(){
        return isAdmin(this.id);
    }

    public static boolean isAdmin(Long id){
        return id != null && id == 1L;
    }



}
